package com.health.fragment.focusgroup.maternity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.health.NovaApplication;
import com.health.PersonalFileActivity.onFragmentSave;
import com.health.R;
import com.health.db.FDbManager;
import com.health.focusgroup.MaternityActivity;
import com.health.fragment.NovaFragment;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.BD_DD_INFO;
import com.health.tablebean.GRAVIDA_BASEINFO;
import com.health.tools.GlobalConts;
import com.health.view.spinner.NiceSpinner;

import android.graphics.Color;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

/**
 * 重点人群-- 孕妇---基本信息
 * 
 * @author nova
 *
 */
public class Maternity_BaseFragment extends NovaFragment implements onFragmentSave {
	// private LayoutInflater inflater = null;
	private View baseView = null;
	// private NovaApplication novaApplication=null;
	private FDbManager fdbmanger = null;
	private ARCHIVE_BASEINFO userInfo;// 基本信息
	private GRAVIDA_BASEINFO gravida_baseInfo;// 孕妇信息

	// --------------------------孕妇信息-------------------------------------
	private TextView tv_idcard;// 身份证号
	private EditText ed_cardno;// 卡号
	private TextView tv_name;// 孕妇姓名
	private TextView tv_age;// 年龄
	private NiceSpinner nice_spinner_culture;// 文化程度
	private NiceSpinner nice_spinner_career;// 职业
	private EditText ed_hkszd;// 户口所在地
	private EditText ed_hk_xz;// 户口乡镇
	private TextView tv_mz;// 民族

	private EditText ed_xzz;// 现住址
	private EditText ed_xzz_xz;// 现住址乡镇
	private EditText ed_xzz_phone;// 现住址电话

	private EditText ed_ch;// 产后休养地
	private EditText ed_ch_xz;// 产后乡镇
	private EditText ed_ch_phone;// 产后电话
	private EditText ed_work;// 工作单位
	private EditText ed_work_phone;// 电话

	// --------------------------丈夫信息-------------------------------------

	private EditText ed_husband_name;// 丈夫姓名
	private EditText ed_husband_age;// 丈夫年龄
	private NiceSpinner nice_spinner_husband_culture;// 文化程度
	private NiceSpinner nice_spinner_nation;// 民族
	private EditText ed_husband_work;// 工作单位
	private EditText ed_husband_phone;// 电话
	private NiceSpinner nice_spinner_husband_career;// 职业
	private int from = -1;// from ==1 从孕妇基本信息数据库处理 from ==0 从基本信息数据库处理

	private List<BD_DD_INFO> minzuList = new ArrayList<BD_DD_INFO>();// 民族列表
	private List<BD_DD_INFO> cultureList = new ArrayList<BD_DD_INFO>();// 文化列表
	private List<BD_DD_INFO> careerList = new ArrayList<BD_DD_INFO>();// 职业列表
	String nice_spinner_culture_pos_str = "";// 文化程度
	String nice_spinner_career_pos_str = "";// 职业
	String nice_spinner_husband_culture_pos_str = "";// 丈夫文化
	String nice_spinner_nation_pos_str = "";// 丈夫民族
	String nice_spinner_husband_career_pos_str = "";// 丈夫 职业
	private NiceSpinner nice_spinner_cc;
	private List<BD_DD_INFO> ccList = new ArrayList<>();
	private String nice_spinner_cc_str ="";

	@Override
	public View findViews(LayoutInflater inflater) {

		fdbmanger = NovaApplication.fdbmanger;
		userInfo = NovaApplication.getUserInfo();
		baseView = inflater.inflate(R.layout.maternity_base, null);

		initViews(baseView);
		//添加 fetusTimes  孕次
		NovaApplication.dbManger.addColumnByBySQL("GRAVIDA_BASEINFO", "fetusTimes");
		GlobalConts.setMaxLength(20, ed_cardno);// 卡号
		GlobalConts.setMaxLength(250, ed_hkszd, // 户口所在地
				ed_hk_xz, // 户口乡镇
				ed_xzz, // 现住址
				ed_xzz_xz, // 现住址乡镇
				ed_ch, // 产后休养地
				ed_ch_xz, // 产后乡镇
				ed_ch_phone, // 产后电话
				ed_work);// 工作单位
		GlobalConts.setMaxLength(20, ed_work_phone, // 电话
				ed_xzz_phone, // 现住址电话
				ed_husband_phone);// 电话
		// ------------丈夫信息--------
		GlobalConts.setMaxLength(25, ed_husband_name);// 丈夫姓名
		GlobalConts.setMaxLength(3, ed_husband_age);// 丈夫年龄
		GlobalConts.setMaxLength(50, ed_husband_work);// 工作单位

		return baseView;
	}

	@Override
	public void setupView(View view) {

	}

	@Override
	public void addListener() {
	}

	@Override
	public void setData() {
		// 设置信息

		bindCareerData();
		bindCultureData();
		bindHusbandMzData();
		bindCCData();
		setData_BaseInfo();
	}

	/**
	 * 绑定产次数据
	 */
	private void bindCCData() {

		ccList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM06-05'  order by cast(SORT as int) asc");
		List<String> cc = new ArrayList<String>();
		cc.add("请选择");
		for (BD_DD_INFO info : ccList) {
			cc.add(info.getDATAINFO());
		}

		nice_spinner_cc.attachDataSource(cc);
		nice_spinner_cc.setText("请选择");


	}

	/**
	 * 设置基本信息
	 * 
	 * @author 王婷婷
	 * @date 2016年1月5日 上午10:11:40
	 */
	private void setData_BaseInfo() {
		if (userInfo != null) {
			List<GRAVIDA_BASEINFO> gradicas = fdbmanger.findAllByWhere(GRAVIDA_BASEINFO.class,
					"IDCARD = '" + userInfo.getIDCARD()+"'");
			if (gradicas.size() > 0) {
				from = 1;
				// 孕妇信息已存在
				gravida_baseInfo = gradicas.get(0);
				NovaApplication.gravida_baseInfo = gravida_baseInfo;
				tv_idcard.setText(gravida_baseInfo.getIDCARD());
				ed_cardno.setText(gravida_baseInfo.getCARDNUM());
				tv_name.setText(gravida_baseInfo.getNAME());

				tv_age.setText(gravida_baseInfo.getAGE());

				// 设置文化程度
				List<BD_DD_INFO> bd_cultuls = getBDById(gravida_baseInfo.getCULTURE());
				if (bd_cultuls != null) {
					nice_spinner_culture_pos_str = gravida_baseInfo.getCULTURE();// 文化程度
					nice_spinner_culture.setText(bd_cultuls.get(0).getDATAINFO());
				}
				// 设置职业
				List<BD_DD_INFO> bd_jobs = getBDById(gravida_baseInfo.getJOB());
				if (bd_jobs != null) {
					nice_spinner_career_pos_str = gravida_baseInfo.getJOB();// 职业

					nice_spinner_career.setText(bd_jobs.get(0).getDATAINFO());
				}

				// 设置产次
				List<BD_DD_INFO> bd_cc = getBDById(gravida_baseInfo.getFetusTimes());
				if (bd_cc != null) {
					nice_spinner_cc_str = gravida_baseInfo.getFetusTimes();// 产次

					nice_spinner_cc.setText(bd_cc.get(0).getDATAINFO());
				}
				// TODO
				// 户口所在地
				ed_hkszd.setText(gravida_baseInfo.getHOUSEHOLD_TOWN());
				ed_hk_xz.setText(gravida_baseInfo.getHOUSEHOLD_VILLAGE());

				tv_mz.setText(gravida_baseInfo.getNATION());
				// ed_xzz; ed_xzz_xz; ed_xzz_phone; ed_ch;// 产后休养地
				// ed_ch_xz; ed_ch_phone; ed_work;ed_work_phone;// 电话
				ed_xzz.setText(gravida_baseInfo.getADDR_TOWN());
				ed_xzz_xz.setText(gravida_baseInfo.getADDR_VILLAGE());
				ed_xzz_phone.setText(gravida_baseInfo.getADDR_PHONE());
				ed_ch.setText(gravida_baseInfo.getTOWNNAME());// 产后休养地
				ed_ch_xz.setText(gravida_baseInfo.getVILLAGENAME());

				ed_ch_phone.setText(gravida_baseInfo.getPW_PHONE());
				ed_work.setText(gravida_baseInfo.getWORKUNIT());
				ed_work_phone.setText(gravida_baseInfo.getUNITPHONE());

				// ed_husband_name;
				// ed_husband_age;nice_spinner_husband_culture;// 文化程度
				// nice_spinner_nation; ed_husband_work; ed_husband_phone;
				// nice_spinner_husband_career;// 职业

				ed_husband_name.setText(gravida_baseInfo.getHUSBAND_NAME());
				ed_husband_age.setText(gravida_baseInfo.getHUSBANDAGE());

				ed_husband_work.setText(gravida_baseInfo.getHUSBANDUNIT());

				ed_husband_phone.setText(gravida_baseInfo.getHUSBAND_PHONE());

				// 设置文化程度

				List<BD_DD_INFO> bd_husband_cultures = getBDById(gravida_baseInfo.getHUSBANDCULTURE());
				if (bd_husband_cultures != null) {
					nice_spinner_husband_culture_pos_str = gravida_baseInfo.getHUSBANDCULTURE();// 丈夫文化
					nice_spinner_husband_culture.setText(bd_husband_cultures.get(0).getDATAINFO());
				}

				// 设置职业
				List<BD_DD_INFO> bd_husband_jobs = getBDById(gravida_baseInfo.getHUSBAND_JOB());
				if (bd_husband_jobs != null) {

					nice_spinner_husband_career_pos_str = gravida_baseInfo.getHUSBAND_JOB();// 丈夫
																							// 职业
					nice_spinner_husband_career.setText(bd_husband_jobs.get(0).getDATAINFO());
				}
				// 设置民族
				List<BD_DD_INFO> bd_husband_nations = getBDById(gravida_baseInfo.getHUSBANDNATION());
				if (bd_husband_nations != null) {
					nice_spinner_nation_pos_str = gravida_baseInfo.getHUSBANDNATION();// 丈夫民族
					nice_spinner_nation.setText(bd_husband_nations.get(0).getDATAINFO());
				}

			} else {
				from = 0;
				// 孕妇信息不存在，改为 基本信息获取
				tv_idcard.setText(userInfo.getIDCARD());
				tv_name.setText(userInfo.getCUSTOMERNAME());
				// 设置年龄
				Date born_time = userInfo.getBIRTHDAY();
				int age = GlobalConts.getAge(born_time);
				if (age != -1) {
					tv_age.setText(String.valueOf(age));
				} else {
					tv_age.setText("");
				}

				tv_mz.setText(userInfo.getMINORITY());

			}

		}

	}

	/**
	 * 通过id查询返回的数据
	 * 
	 * @param str_id
	 * @return
	 * @author 王婷婷
	 * @date 2015年12月15日 下午6:38:52
	 */
	private List<BD_DD_INFO> getBDById(String str_id) {
		if (str_id != null) {

			List<BD_DD_INFO> bds = fdbmanger.findAllByWhereInInfoDB(BD_DD_INFO.class, "ID='" + str_id + "'");
			if (bds.size() > 0) {

				return bds;
			} else {
				return null;
			}
		} else {
			return null;
		}

	}

	/**
	 * 初始化布局信息
	 * 
	 * @param v
	 * @author 王婷婷
	 * @date 2015年12月12日 上午9:37:18
	 */
	private void initViews(View v) {
		// --------------------------孕妇信息-------------------------------------
		tv_idcard = (TextView) v.findViewById(R.id.tv_idcard);
		ed_cardno = (EditText) v.findViewById(R.id.ed_cardno);
		tv_name = (TextView) v.findViewById(R.id.tv_name);
		tv_age = (TextView) v.findViewById(R.id.tv_age);
		nice_spinner_culture = (NiceSpinner) v.findViewById(R.id.nice_spinner_culture);
		nice_spinner_career = (NiceSpinner) v.findViewById(R.id.nice_spinner_career);
		ed_hkszd = (EditText) v.findViewById(R.id.ed_hkszd);
		ed_hk_xz = (EditText) v.findViewById(R.id.ed_hk_xz);
		tv_mz = (TextView) v.findViewById(R.id.tv_mz);

		ed_xzz = (EditText) v.findViewById(R.id.ed_xzz);
		ed_xzz_xz = (EditText) v.findViewById(R.id.ed_xzz_xz);
		ed_xzz_phone = (EditText) v.findViewById(R.id.ed_xzz_phone);

		ed_ch = (EditText) v.findViewById(R.id.ed_ch);
		ed_ch_xz = (EditText) v.findViewById(R.id.ed_ch_xz);
		ed_ch_phone = (EditText) v.findViewById(R.id.ed_ch_phone);
		ed_work = (EditText) v.findViewById(R.id.ed_work);
		ed_work_phone = (EditText) v.findViewById(R.id.ed_work_phone);

		// --------------------------丈夫信息-------------------------------------

		ed_husband_name = (EditText) v.findViewById(R.id.ed_husband_name);
		ed_husband_age = (EditText) v.findViewById(R.id.ed_husband_age);
		nice_spinner_husband_culture = (NiceSpinner) v.findViewById(R.id.nice_spinner_husband_culture);
		nice_spinner_nation = (NiceSpinner) v.findViewById(R.id.nice_spinner_nation);
		ed_husband_work = (EditText) v.findViewById(R.id.ed_husband_work);
		ed_husband_phone = (EditText) v.findViewById(R.id.ed_husband_phone);
		nice_spinner_husband_career = (NiceSpinner) v.findViewById(R.id.nice_spinner_husband_career);
		nice_spinner_cc = (NiceSpinner) v.findViewById(R.id.nice_spinner_cc);

	}

	/**
	 * 
	 * 
	 * @author 王婷婷
	 * @date 2015年12月14日 上午9:51:02
	 */
	private void saveData() {
		GRAVIDA_BASEINFO baseinfo = new GRAVIDA_BASEINFO();
		String str_husName = ed_husband_name.getText().toString();
		if (TextUtils.isEmpty(str_husName)) {
			ed_husband_name.setBackgroundColor(Color.YELLOW);
			((MaternityActivity) getActivity()).showTextDialog("请填写丈夫姓名");
			return;
		} else {
			ed_husband_name.setBackgroundColor(Color.WHITE);
			baseinfo.setHUSBAND_NAME(str_husName);
		}
		
		String str_husPhone = ed_husband_phone.getText().toString();
		if (TextUtils.isEmpty(str_husPhone)) {
			ed_husband_phone.setBackgroundColor(Color.YELLOW);
			((MaternityActivity) getActivity()).showTextDialog("请填写丈夫电话");
			return;
		} else {
			if(!GlobalConts.isPhoneNumberValid(str_husPhone)){
				((MaternityActivity) getActivity()).showTextDialog("请填写正确的丈夫电话");
				return;
			}
			ed_husband_phone.setBackgroundColor(Color.WHITE);
			baseinfo.setHUSBAND_PHONE(str_husPhone);
//			baseinfo.setHB_UNITPHONE(str_husPhone);
		}

		int nice_spinner_cc_pos = nice_spinner_cc.getSelectedIndex();
		if (nice_spinner_cc_pos == 0){
			nice_spinner_cc.setBackgroundColor(Color.YELLOW);
			((MaternityActivity) getActivity()).showTextDialog("请填产次");
			return;
		}else{
			baseinfo.setFetusTimes(ccList.get(nice_spinner_cc.getSelectedIndex()-1).getID());
		}
		
		// tv_idcard;ed_cardno;tv_name; tv_age; nice_spinner_culture;
		// nice_spinner_career;// 职业
		// ed_hkszd;ed_hk_xz; tv_mz;ed_xzz; ed_xzz_xz; ed_xzz_phone; ed_ch;//
		// 产后休养地
		// ed_ch_xz; ed_ch_phone; ed_work;ed_work_phone;// 电话

		baseinfo.setADDR(userInfo.getADDR());
		baseinfo.setBIRTHDAY(userInfo.getBIRTHDAY());
		baseinfo.setARCHIVEID("");// 设置档案编号
		baseinfo.setIDCARD(tv_idcard.getText().toString());
		baseinfo.setCARDNUM(ed_cardno.getText().toString());
		baseinfo.setNAME(tv_name.getText().toString());
		baseinfo.setAGE(tv_age.getText().toString());

		// 设置 文化程度
		int nice_spinner_culture_pos = nice_spinner_culture.getSelectedIndex();

		if (nice_spinner_culture_pos != 0) {
			nice_spinner_culture_pos_str = cultureList.get(nice_spinner_culture_pos - 1).getID();
		}

		baseinfo.setCULTURE(nice_spinner_culture_pos_str);

		// 设置 职业
		int nice_spinner_career_pos = nice_spinner_career.getSelectedIndex();

		if (nice_spinner_career_pos != 0) {
			nice_spinner_career_pos_str = careerList.get(nice_spinner_career_pos - 1).getID();
		}

		baseinfo.setJOB(nice_spinner_career_pos_str);

		baseinfo.setCARDNUM(ed_cardno.getText().toString());
		baseinfo.setHOUSEHOLD_TOWN(ed_hkszd.getText().toString());
		baseinfo.setHOUSEHOLD_VILLAGE(ed_hk_xz.getText().toString());
		baseinfo.setNATION(tv_mz.getText().toString());

		baseinfo.setADDR_TOWN(ed_xzz.getText().toString());
		baseinfo.setADDR_VILLAGE(ed_xzz_xz.getText().toString());

		baseinfo.setADDR_PHONE(ed_xzz_phone.getText().toString());
		baseinfo.setTOWNNAME(ed_ch.getText().toString());

		baseinfo.setVILLAGENAME(ed_ch_xz.getText().toString());
		baseinfo.setPW_PHONE(ed_ch_phone.getText().toString());
		baseinfo.setWORKUNIT(ed_work.getText().toString());
		baseinfo.setUNITPHONE(ed_work_phone.getText().toString());

		
		baseinfo.setHUSBANDAGE(ed_husband_age.getText().toString());

		// 丈夫文化程度
		int nice_spinner_husband_culture_pos = nice_spinner_husband_culture.getSelectedIndex();

		if (nice_spinner_husband_culture_pos != 0) {
			nice_spinner_husband_culture_pos_str = cultureList.get(nice_spinner_husband_culture_pos - 1).getID();
		}
		baseinfo.setHUSBANDCULTURE(nice_spinner_husband_culture_pos_str);

		// 丈夫文化程度
		int nice_spinner_nation_pos = nice_spinner_nation.getSelectedIndex();

		if (nice_spinner_nation_pos != 0) {
			nice_spinner_nation_pos_str = minzuList.get(nice_spinner_nation_pos - 1).getID();
		}

		baseinfo.setHUSBANDNATION(nice_spinner_nation_pos_str);
		baseinfo.setHUSBANDUNIT(ed_husband_work.getText().toString());

		// 设置丈夫职业
		int nice_spinner_husband_career_pos = nice_spinner_husband_career.getSelectedIndex();

		if (nice_spinner_husband_career_pos != 0) {
			nice_spinner_husband_career_pos_str = careerList.get(nice_spinner_husband_career_pos - 1).getID();
		}

		baseinfo.setHUSBAND_JOB(nice_spinner_husband_career_pos_str);
		
		if (from == 0) {
			// 从基本信息库读取
			baseinfo.setCREATED_BY(userInfo.getCREATED_BY());
			baseinfo.setCREATED_DATE(new Date());
			baseinfo.setCREATEORG(userInfo.getCREATEORG());
			baseinfo.setCREATER(userInfo.getCREATED_BY());
			FDbManager.getInstance(getActivity()).save(baseinfo);
			from = 1;
		} else {
			baseinfo.setLAST_UPDATE_DATE(new Date());
			baseinfo.setLAST_UPDATE_BY(userInfo.getCREATED_BY());
			baseinfo.setUPDATEORG(userInfo.getCREATEORG());
			baseinfo.setMODIFIED(userInfo.getCREATED_BY());
			// 从孕妇信息库读取，修改孕妇信息
			FDbManager.getInstance(getActivity()).updata(baseinfo, "IDCARD='" + tv_idcard.getText().toString() + "'");

		}
		NovaApplication.gravida_baseInfo = baseinfo;
		((MaternityActivity) getActivity()).showTextDialog("保存成功");
	}

	/**
	 * 绑定民族
	 * 
	 * @author 王婷婷
	 * @date 2015年12月14日 下午1:29:53
	 */
	private void bindHusbandMzData() {
		minzuList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-01'  order by cast(SORT as int) asc");
		List<String> minzu = new ArrayList<String>();
		minzu.add("请选择");
		for (BD_DD_INFO info : minzuList) {
			minzu.add(info.getDATAINFO());
		}
		nice_spinner_nation.attachDataSource(minzu);
		nice_spinner_nation.setText("汉族");
	}

	/**
	 * 绑定文化程度
	 * 
	 * @author 王婷婷
	 * @date 2015年12月14日 下午1:29:53
	 */
	private void bindCultureData() {
		cultureList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-02'  order by cast(SORT as int) asc");
		List<String> minzu = new ArrayList<String>();
		minzu.add("请选择");
		for (BD_DD_INFO info : cultureList) {
			minzu.add(info.getDATAINFO());
		}
		nice_spinner_culture.attachDataSource(minzu);
		nice_spinner_culture.setText("请选择");

		nice_spinner_husband_culture.attachDataSource(minzu);
		nice_spinner_husband_culture.setText("请选择");
	}

	/**
	 * 绑定职业
	 * 
	 * @author 职业
	 * @date 2015年12月14日 下午1:29:53
	 */
	private void bindCareerData() {
		careerList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-14'   order by cast(SORT as int) asc");

		List<String> minzu = new ArrayList<String>();
		minzu.add("请选择");
		for (BD_DD_INFO info : careerList) {
			minzu.add(info.getDATAINFO());
		}
		nice_spinner_career.attachDataSource(minzu);
		nice_spinner_career.setText("请选择");

		nice_spinner_husband_career.attachDataSource(minzu);
		nice_spinner_husband_career.setText("请选择");
	}

	@Override
	public void save() {

		checkData();

	}

	/**
	 * 验证数据是否符合规范
	 * 
	 * @author 王婷婷
	 * @date 2016年2月1日 下午2:29:54
	 */
	private void checkData() {
		// 卡号认证
		String str_cardno = ed_cardno.getText().toString();
		if (!TextUtils.isEmpty(str_cardno)) {
			if (!GlobalConts.isSpecialSymbols(str_cardno)) {
				ed_cardno.setBackgroundColor(Color.YELLOW);
				((MaternityActivity) getActivity()).showTextDialog("请输入正确的卡号");
				return;
			} else {
				ed_cardno.setBackgroundColor(Color.WHITE);
			}
		} else {
			ed_cardno.setBackgroundColor(Color.WHITE);
		}

		// 现住址电话
		String str_xzz = ed_xzz_phone.getText().toString();
		if (!TextUtils.isEmpty(str_xzz)) {
			if (!GlobalConts.isPhoneNumberValid(str_xzz)) {
				((MaternityActivity) getActivity()).showTextDialog("请输入正确的现住址电话");
				ed_xzz_phone.setBackgroundColor(Color.YELLOW);
				return;
			} else {
				ed_xzz_phone.setBackgroundColor(Color.WHITE);
			}
		} else {
			ed_xzz_phone.setBackgroundColor(Color.WHITE);
		}

		// 产后休养地 电话
		String str_ch_phone = ed_ch_phone.getText().toString();
		if (!TextUtils.isEmpty(str_ch_phone)) {
			if (!GlobalConts.isPhoneNumberValid(str_ch_phone)) {
				ed_ch_phone.setBackgroundColor(Color.YELLOW);
				((MaternityActivity) getActivity()).showTextDialog("请输入正确的产后休养地电话");
				return;
			} else {
				ed_ch_phone.setBackgroundColor(Color.WHITE);
			}
		} else {
			ed_ch_phone.setBackgroundColor(Color.WHITE);
		}

		// 工作单位电话
		String str_work_phone = ed_work_phone.getText().toString();
		if (!TextUtils.isEmpty(str_work_phone)) {
			if (!GlobalConts.isPhoneNumberValid(str_work_phone)) {
				ed_work_phone.setBackgroundColor(Color.YELLOW);
				((MaternityActivity) getActivity()).showTextDialog("请输入正确的工作单位电话");
				return;
			} else {
				ed_work_phone.setBackgroundColor(Color.WHITE);
			}
		} else {
			ed_work_phone.setBackgroundColor(Color.WHITE);
		}

//		// 丈夫 工作单位电话
//		String str_husband_phone = ed_husband_phone.getText().toString();
//		if (!TextUtils.isEmpty(str_husband_phone)) {
//			if (!GlobalConts.isPhoneNumberValid(str_husband_phone)) {
//				ed_husband_phone.setBackgroundColor(Color.YELLOW);
//				((MaternityActivity) getActivity()).showTextDialog("请输入丈夫正确的工作单位电话");
//				return;
//			} else {
//				ed_husband_phone.setBackgroundColor(Color.WHITE);
//			}
//		} else {
//			ed_husband_phone.setBackgroundColor(Color.WHITE);
//		}

		saveData();

	}

}
